package WaiBao;

import java.util.Arrays;

public class YanHui {
    public static void main(String[] args) {
        String[] name = {"花花(纪律委员)", "悄悄(班长)", "小海(组织委员)", "超超(体育委员)", "张大大", "四四", "王小小", "浩辰", "李飞", "杜甫", "赵煜来", "裴东来",
                "赵怀安", "李勋", "刘嘟嘟", "尼康", "还珠格格", "凌耀东", "凌耀华", "林中会", "杨过", "白水", "李训", "马云", "马嘟嘟", "马化腾", "雷军", "王磊",
                "王帅", "闫慧(团支书)"};//考生本人: 闫慧(团支书)
        int[] age = {19, 21, 19, 19, 19, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 20, 19};
        double[] SW = {88, 82, 84, 90, 68, 69, 78, 89, 80, 90, 90, 87, 85, 79, 65, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 74, 74, 80, 90};
        double[] WSW = {78, 85, 69, 66, 68, 67, 88, 79, 90, 90, 90, 77, 86, 75, 65, 65, 86, 79, 66, 68, 92, 71, 95, 85, 75, 84, 74, 64, 90, 91};
        double[] RT = {78, 96, 80, 95, 79, 69, 78, 89, 80, 60, 93, 87, 85, 75, 65, 68, 69, 69, 96, 93, 92, 81, 95, 95, 76, 84, 73, 71, 89, 94};

        double X;//代表每个学生的总分
        double Avg;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            X = SW[i] + WSW[i] + RT[i];
//            Avg = (X * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + X);
//            System.out.println(name[i] + "的平均分为:" + Avg);
//        }
//
        double result = 0, average = 0;
        double[] array = new double[30];
//        for (int i = 0; i < 30; i++) {
//            result = SW[i] + WSW[i] + RT[i];
//            average = (result * 1.0) / 3;
//            array[i] = average;
//        }
//
//        for (int i = 0; i < array.length - 1; i++) {
//            for (int j = 0; j < array.length - i - 1; j++) {
//                if (array[j] < array[j + 1]) {
//                    double tep = array[j];
//                    array[j] = array[j + 1];
//                    array[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(array[i]);
//        }


        double p1 = 0, p2 = 0, p3 = 0;//计算每门课的平均分
        double v1 = 0, v2 = 0, v3 = 0;//计算每门课标准差
        double n1 = 0, n2 = 0, n3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i < SW.length; i++) {
            sum2 += SW[i];
        }
        p1 = (sum2 * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + p1);
        double Sum = 0;
        for (int i = 0; i < WSW.length; i++) {
            Sum += WSW[i];
        }
        p2 = (Sum * 1.0) / 30;
        System.out.println("微生物学的班级平均分为:" + p2);
        double sum = 0;
        for (int i = 0; i < RT.length; i++) {
            sum += RT[i];
        }
            p3 = (sum * 1.0) / 30;
            System.out.println("人体组织解剖学的班级平均分为:" + p3);

            double c1 = 0, c2 = 0, c3 = 0;
            for (int i = 0; i < SW.length; i++) {
                c1 += (SW[i] - p1) * (SW[i] - p1);
            }
            v1 = Math.sqrt(c1*1.0/30);
            System.out.println("生物化学的班级标准差为:" + v1);
            for (int i = 0; i < WSW.length; i++) {
                c2 += (WSW[i] - p2) * (WSW[i] - p2);
            }
            v2 = Math.sqrt(c2*1.0/30);
            System.out.println("微生物学的班级标准差为:" + v2);

            for (int i = 0; i < RT.length; i++) {
                c3 += (RT[i] - p3) * (RT[i] - p3);
            }
            v3 = Math.sqrt(c3*1.0/30);
            System.out.println("人体组织解剖学的班级标准差为:" + v3);
//
//            Arrays.sort(SW);
//            Arrays.sort(WSW);
//            Arrays.sort(RT);
//            n1 = (SW[15] + SW[16]) * 1.0 / 2;
//            n2 = (WSW[15] + WSW[16]) * 1.0 / 2;
//            n3 = (RT[15] + RT[16]) * 1.0 / 2;
//            System.out.println("生物化学的中位数为:" + n1);
//            System.out.println("微生物学的中位数为:" + n2);
//            System.out.println("人体组织解剖学的中位数为:" + n3);
    }
}
